﻿@using Models
@model List<PrivateMessage>
@{
    ViewBag.Title = "Received private message";
}

<h2>Received private message</h2>


@if(Model != null)
{
        var id = Convert.ToInt32(Request.RequestContext.RouteData.Values["id"]);
    
    <table id="table_admin">
   
    @if (id != 0)
    {
        var pm = Model[0];

        <tr>
            <td>
                @pm.Title
            </td>    
            <td>
                @pm.SendDate.GetDateTimeFormats()[15]
            </td>
        </tr>
        <tr>
            <td>
                <a href="/users/index/@pm.Sender.Login">@pm.Sender.Login</a>
            </td>
            <td>@pm.Text</td>
        </tr>
    }
       
else
{
    foreach (PrivateMessage pm in Model)
    {
                <tr>
                    <td>
                      <a href="/AccountControll/PM/@pm.Id"> @pm.Title</a>
                    </td>    
                <td>
                    <a href="/users/index/@pm.Sender.Login">@pm.Sender.Login</a>
                </td>
                </tr>
    }
                }
                 </table>
}
else
{
    <span>No message</span>
}